<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Promise.reject()的使用</title>
</head>
<body>
    <script>
        let hd = {
            then(resolve,reject){
                resolve("成功");
            }
        };

        Promise.resolve(hd).then(
            value => console.log(value)
        )

        Promise.reject('失败').then(
            value => console.log(value)
        ).catch(
            error => console.log(error)
        )




        new Promise((resolve,reject) => {
            resolve("successsssss")
        }).then(
            value => {
                if(value != 'success'){
                    // 方法一：抛异常
                    // throw new Error("fail");
                    
                    // 方法二：Promise.reject()
                    return Promise.reject("fail");
                }
            }
        ).catch(
            error => console.log(error)
        )
    </script>
</body>
</html>